home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #6 / Amiga Plus CD - 1996 - No. 06.iso / pd / tools / frexxed / fpl / mhead.fpl < prev    next >
Text File  |  1996-03-17  |  3KB  |  128 lines

  1.  
  2. export void ReadSettings()
  3. {
  4.   int ps,a,b,c,d,e,dn;
  5.   string nam,val,lin;
  6.   lin=GetLine(1);
  7.   if (0==strstr(lin,ReadInfo("HeaderStart"))){
  8.   a=1;lin=GetLine(2);dn=0;
  9.   while (!dn)
  10.   {
  11.     b=a;if (lin[a]=='#'){dn=1;};
  12.     if (!dn)
  13.     { a++;
  14.       while (lin[a] != '$') {a++;};
  15.       c=a;
  16.       ps=0;if (lin[b]=='S'){ps=1;};
  17.       d=1;while(lin[b+d]!='='){d++;};
  18.       nam=substr(lin,b+1,d-1);e=1;
  19.       while(lin[b+d+e]!='$'){e++;};
  20.       val=substr(lin,b+d+1,e-1);
  21.       if (ps)
  22.        {SetInfo(0,nam,val);}else
  23.        {SetInfo(0,nam,atoi(val));};
  24.     };a++;
  25.   };};
  26. }
  27.  
  28.  
  29. export void InsertSetting(string name,int typ)
  30. {
  31.  string val;
  32.  if (typ==0) {val=ReadInfo(name);}
  33.   else{ 
  34.  val=itoa(ReadInfo(name));}; 
  35.  Output("$");
  36.  if (typ==0) {Output("S");}else{Output("I");};
  37.  Output(name);
  38.  Output("=");Output(val);
  39. }
  40.  
  41. export void WriteSettings()
  42. {
  43.   InsertSetting("system_font",0);
  44.   InsertSetting("request_font",0);
  45.   InsertSetting("public_screen",0);
  46.   InsertSetting("current_screen",0);
  47.   InsertSetting("window",1);
  48.   InsertSetting("copy_wb",1);
  49.   InsertSetting("display_id",1);
  50.   InsertSetting("insert_mode",1);
  51.   InsertSetting("keymap",0);
  52.   InsertSetting("language",0);
  53.   InsertSetting("marg_left",1);
  54.   InsertSetting("marg_lower",1);
  55.   InsertSetting("marg_right",1);
  56.   InsertSetting("marg_upper",1);
  57.   InsertSetting("overscan",1);
  58.   InsertSetting("popup_view",1);
  59.   InsertSetting("tab_size",1);
  60.   InsertSetting("window_height",1);
  61.   InsertSetting("window_pos",1);
  62.   InsertSetting("window_width",1);
  63.   InsertSetting("window_xpos",1);
  64.   InsertSetting("window_ypos",1);
  65.   InsertSetting("screen_depth",1);
  66.   InsertSetting("screen_height",1);
  67.   InsertSetting("screen_width",1);
  68.   InsertSetting("slider",1);
  69. }
  70.  
  71. export string GetVersion()
  72. {
  73.   string ver=GetLine(3);
  74.   if (0==strncmp(ver,"$VER: ",5))
  75.    {ver=substr(ver,6,strlen(ver)-7);};
  76.   return(ver);
  77. }
  78.  
  79. export void PutVersion(string ver)
  80. {
  81.   if (0==strncmp(GetLine(3),"$VER: ",5))
  82.    { GotoLine(3);DeleteLine(1);
  83.    }
  84.   Output("$VER: ");Output(ver);Output("\n");
  85. }
  86.  
  87. export void NewHeader()
  88.  {
  89.   Visible(0);GotoLine(1,0);
  90.   Output(ReadInfo("HeaderStart"));Output("\n\n\n");
  91.   GotoLine(2,0);
  92.   WriteSettings();
  93.   Output("$#");
  94.   GotoLine(3,0);Output("$VER: ");
  95.   GotoLine(4,0);Output(ReadInfo("HeaderEnd"));Output("\n");Visible(1);
  96.  }
  97.  
  98. export void MakeHeader()
  99. {
  100.   GotoLine(2,0);DeleteLine(1);
  101.   WriteSettings();
  102.   Output("$#\n");
  103.   PutVersion(PromptString(GetVersion(),"Header","Enter version string"));
  104.  
  105. }
  106.  
  107. export int SaveHook()
  108. { int x=ReadInfo("cursor_x"),y=ReadInfo("cursor_y");
  109.  Visible(0);
  110.  if (0==strstr(GetLine(1),ReadInfo("HeaderStart"))){MakeHeader();};
  111.  GotoLine(y,x-1);Visible(1);return(0);
  112. }
  113.  
  114. export int LoadHook()
  115. {
  116.  Visible(0);
  117.  ReadSettings();
  118.  Visible(1);return(0);
  119. }
  120.  
  121.  
  122. ConstructInfo("HeaderStart","","","GSW","",0,0,"$FrexxHead");
  123. ConstructInfo("HeaderEnd","","","GSW","",0,0,"$EndHead");
  124.  
  125. Hook("Save","SaveHook();");
  126. HookPast("Load","LoadHook();");
  127. AssignKey("NewHeader();","Amiga ä");
  128.